package com.itheima;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.annotation.WebServlet;
import java.io.IOException;

//配置指定顺序执行

@WebFilter(value ="/Servlet",dispatcherTypes= {DispatcherType.REQUEST,DispatcherType.FORWARD,DispatcherType.INCLUDE})

public class FilterDemo1 implements Filter {

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("FilterDemo1执行了");
        //往域中存取数据
        servletRequest.setAttribute("username","admin");
        //放行
        filterChain.doFilter(servletRequest,servletResponse);
    }
}
